<!--
 * @Author: your name
 * @Date: 2022-03-31 17:39:00
 * @LastEditTime: 2022-03-31 17:40:49
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\浅拷贝实现方式220331.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>浅拷贝实现方式2</title>
</head>

<body>
  <script>
    let obj1 = {
      name: '歌谣',
      address: {
        x: 100,
        y: 100
      }
    }
    let obj2 = {
      ...obj1
    }
    obj1.address.x = 200;
    obj1.name = '方方'
    console.log('obj2', obj2) // obj2 { name: '方方', address: { x: 200, y: 100 } }
  </script>
</body>

</html>